package vip.xiaonuo.modular.manage.theme.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import vip.xiaonuo.modular.manage.theme.entity.BiThemeIndex;
import vip.xiaonuo.modular.manage.theme.mapper.ThemeIndexMapper;
import vip.xiaonuo.modular.manage.theme.param.ThemeIndexParam;
import vip.xiaonuo.modular.manage.theme.service.ThemeIndexService;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description
 * @Author cy
 * @Date 2022/8/1 19:19
 * @Version 1.0
 */
@Service
public class ThemeIndexServiceImpl extends ServiceImpl<ThemeIndexMapper, BiThemeIndex> implements ThemeIndexService {

    @Override
    public List<BiThemeIndex> list(ThemeIndexParam themeIndexParam) {
        LambdaQueryWrapper<BiThemeIndex> wrapper = new LambdaQueryWrapper();
        wrapper.eq(BiThemeIndex::getThemeId,themeIndexParam.getThemeId());
        return getBaseMapper().selectList(wrapper);
    }


    @Override
    public List<Long> findindexIds(Long themeId) {
        QueryWrapper<BiThemeIndex> queryWrapper=new QueryWrapper<>();
        queryWrapper.lambda().eq(BiThemeIndex::getPoiOrIndex,"indexType");
        queryWrapper.lambda().eq(BiThemeIndex::getThemeId,themeId);
        List<BiThemeIndex> list = this.list(queryWrapper);
        List<Long> ids = new ArrayList<>();
        for (BiThemeIndex biThemeIndex : list) {
            ids.add(biThemeIndex.getIndexId());
        }
        return ids;
    }

    @Override
    public List<Long> findPoiIds(Long themeId) {
        QueryWrapper<BiThemeIndex> queryWrapper=new QueryWrapper<>();
        queryWrapper.lambda().eq(BiThemeIndex::getPoiOrIndex,"poiType");
        queryWrapper.lambda().eq(BiThemeIndex::getThemeId,themeId);
        List<BiThemeIndex> list = this.list(queryWrapper);
        List<Long> ids = new ArrayList<>();
        for (BiThemeIndex biThemeIndex : list) {
            ids.add(biThemeIndex.getPoiId());
        }
        return ids;
    }
}
